/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.itsc.dswII.view;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import mx.itsc.dswII.bl.PersonalBlLocal;
import mx.itsc.dswII.model.Persona;

/**
 *
 * @author Lenovo-user
 */
@ManagedBean
@SessionScoped
public class AccessBean {

    @EJB
    private PersonalBlLocal personalBl;
    private String user = "";
    private String pass = "";
    private Persona persona;

    public Persona getPersona() {
        return persona;
    }

    public void setPersona(Persona persona) {
        this.persona = persona;
    }

    public AccessBean() {
    }

    public String getUser() {
        return user;
    }

    public void setUser(String user) {
        this.user = user;
    }

    public String getPass() {
        return pass;
    }

    public void setPass(String pass) {
        this.pass = pass;
    }
    //++++++++Action++++

    public String procesarAccion() {
        String page = " ";

        for (Persona usu : personalBl.getAll()) {
            if (user.equalsIgnoreCase(usu.getNombre()) && pass.equalsIgnoreCase(usu.getNombre())) {

                page = "MenuPrincipal";

            } else if (user.equalsIgnoreCase("root") && pass.equalsIgnoreCase("12345")) {
                page = "MenuPrincipal";
            } else {
            page= "Error";
            }
        }
        return page;
    }
}
